#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int maxArea(vector<int>& height)
    {
        int left = 0;
        int right = height.size() - 1;
        int area = 0;

        while (left < right)
        {
            int v = (right - left) * min(height[left], height[right]);
            area = max(area, v);
            if (height[right] > height[left])
            {
                left++;
            }
            else
            {
                right--;
            }
        }
        return area;
    }
};